import {nanoid} from "nanoid";

export default function getUserTempId() {
    //先去本地存储中获取是否有用户临时标识
    let userTempId = localStorage.getItem("userTempId");
    //如果本地存在,则直接返回这个id
    if (userTempId) return userTempId;
    
    //不存在则返回一个新的
    userTempId = nanoid();
    localStorage.setItem("userTempId", userTempId);
    return userTempId;
  }